import { FormSchema } from '/@/components/Table';
const isWebscoket = (type) => type === 'WEBSOCKET';
const isGBT = (type) => type === 'GBT32960' || type === 'V2C';
const isV2C = (type) => type === 'V2C';
export const formSchema: FormSchema[] = [
  {
    label: 'id',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    label: '名称',
    field: 'protocolType',
    component: 'Input',
    show: false,
  },
  {
    label: '描述',
    field: 'desc',
    component: 'Input',
    show: false,
  },
  {
    field: 'port',
    label: '端口',
    component: 'Input',
    required: true,
  },
  {
    field: 'path',
    label: '连接路径',
    component: 'JInput',
    defaultValue: '/{clientId}',
    ifShow: ({ values }) => isWebscoket(values.protocolType),
  },
  {
    field: 'basicAuth',
    label: 'Basic认证',
    component: 'JSwitch',
    defaultValue: true,
    componentProps: {
      options: [true, false],
    },
    ifShow: ({ values }) => isWebscoket(values.protocolType),
  },
  {
    field: 'divider-linked',
    component: 'Divider',
    label: 'AES加密',
    ifShow: ({ values }) => isGBT(values.protocolType),
  },
  {
    field: 'aesSecretKey',
    label: '密钥',
    component: 'Input',
    ifShow: ({ values }) => isGBT(values.protocolType),
  },
  {
    field: 'divider-linked',
    component: 'Divider',
    label: 'RSA加密',
    ifShow: ({ values }) => isGBT(values.protocolType),
  },
  {
    field: 'rsaPublicKey',
    label: '公钥',
    component: 'Input',
    ifShow: ({ values }) => isGBT(values.protocolType),
  },
  {
    field: 'rsaSecretKey',
    label: '私钥',
    component: 'Input',
    ifShow: ({ values }) => isGBT(values.protocolType),
  },
  {
    field: 'divider-linked',
    component: 'Divider',
    label: 'SM2加密',
    ifShow: ({ values }) => isV2C(values.protocolType),
  },
  {
    field: 'sm2SecretKey',
    label: '密钥',
    component: 'Input',
    ifShow: ({ values }) => isV2C(values.protocolType),
  },
  {
    field: 'divider-linked',
    component: 'Divider',
    label: 'SM4加密',
    ifShow: ({ values }) => isV2C(values.protocolType),
  },
  {
    field: 'sm4SecretKey',
    label: '密钥',
    component: 'Input',
    ifShow: ({ values }) => isV2C(values.protocolType),
  },
];

export const formSchema1: FormSchema[] = [
  {
    field: 'port',
    label: '端口',
    component: 'Input',
  },
  {
    field: 'startTime',
    label: '启动时间',
    component: 'Input',
  },
  {
    field: 'downTopic',
    label: '下行Topic',
    component: 'Input',
  },
  {
    field: 'upTopic',
    label: '上行Topic',
    component: 'Input',
  },
  {
    field: 'secondSendQps',
    label: '发送数/秒',
    component: 'Input',
  },
  {
    field: 'secondReceiveQps',
    label: '接收数/秒',
    component: 'Input',
  },
  {
    field: 'minuteSendQps',
    label: '发送数/分钟',
    component: 'Input',
  },
  {
    field: 'minuteReceiveQps',
    label: '接收数/分钟',
    component: 'Input',
  },
  {
    field: 'sendCount',
    label: '发送总数',
    component: 'Input',
  },
  {
    field: 'receiveCount',
    label: '接收总数',
    component: 'Input',
  },
];

export interface ActionBtn {
  img?: string;
  click?: object;
  isshow?: boolean;
  name?: string;
  params?: string;
}

export const actionBtns: ActionBtn[] = [
  {
    img: '',
    click: {
      isshow: false,
      name: 'handleRun',
    },
  },
  {
    img: '',
    click: {
      isshow: false,
      name: 'handleEdit',
    },
  },
  {
    img: '',
    click: {
      isshow: true,
      name: 'handleRun',
    },
  },
  {
    img: '',
    click: {
      defaultshow: true,
      name: 'handleDetail',
    },
  },
  {
    img: '',
    click: {
      isshow: false,
      name: 'handleDelete',
    },
  },
];
export interface Extension {
  img?: string;
  protocolType?: string;
  desc?: string;
}
export const extensions: Extension[] = [
  {
    img: '',
    protocolType: 'COAP',
    desc: 'CoAP是一种基于UDP轻量级的通信协议',
  },
  {
    img: '',
    protocolType: 'WEBSOCKET',
    desc: '基于标准WebSocket协议实现，支持Basic密码认证',
  },
  {
    img: '',
    protocolType: 'I1',
    desc: '基于TCP实现的QGDW_1242-2015输电线路通信协议',
  },
  {
    img: '',
    protocolType: 'GBT32960',
    desc: '基于TCP实现的GB/T32960 电动汽车远程服务与管理系统技术规范',
  },
  {
    img: '',
    protocolType: 'V2C',
    desc: '基于TCP实现的V2X智能网联汽车云控系统车云数据交互规范',
  },
];
